/**
 * 压缩:htm(混合style|script)  非语法解析
 * @param code string 代码
 * @param ign array|null HTM忽略片段的正则
 * 		内部忽略: <pre/>标签内容
 * @return string
 */
$.astMinHtm = function(code, ign=null) {
	const CSS = /<style((?:.|\n)*)?>((?:.|\n)*?)<\/style\s*>/gi;
	const ES6 = /<script((?:.|\n)*?)>((?:.|\n)*?)<\/script\s*>/gi;
	const IGN = /<!--(.|\n)*?-->/g, TYP=/type=["'](.*?)["']/i;
	const TPS = ['application/javascript','text/babel','module'];
	const ENC = '<___$_astMinHtm___:';
	$.astMinHtm = function(code, ign=null){
		let tmp={}, idx=0;  code=code.replace(IGN,'');
		code = code.replace(CSS, (m,attr,css)=>{
			tmp[idx] = '<style'+attr+'>'+$.astMinCss(css)+'</style>';
			return ENC+(idx++)+'$>';
		});
		code = code.replace(ES6, (m,attr,txt) => {
			let ms=attr.match(TYP), typ=ms&&ms[1].toLowerCase();
			if(typ==='text/template') txt = $.astMinXml(txt, ign);
			else if(!typ || TPS.includes(typ)) txt=$.astMinEs6(txt);
			tmp[idx] = '<script'+attr+'>'+txt+'</script>';
			return ENC+(idx++)+'$>';
		});
		code = $.astMinXml(code, ign);
		for(let i=0; i<idx; i++) code=code.replace(ENC+i+'$>',tmp[i]);
		return code;
	};
	return $.astMinHtm(code, ign);
};
